package cate.game.role.res.guild.msg.basic;

import cate.game.GameBody;
import cate.game.chat.ChatRequest;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdGuild;
import cate.game.role.Role;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "重置公会宣言 的 请求")
public class ResetDeclarationReq implements MsgInput {

    @NoteField(value = "宣言")
    public String declaration;

    @NoteField(value = "公会宣言内容验证")
    public String checkSign;

    public ResetDeclarationReq() {
    }

    @Override
    public MsgConfig conf() {
        return MsgIdGuild.RESET_DECLARATION_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        h(game, cc.getRole());
    }

    public void h(GameBody game, Role role) {
        perform(game, role, () -> {
            if (!role.getRes().guild.checkGuild().ok()) {
                game.notice.message(role,310450,"尚未加入公会");
                return;
            }
            ChatRequest.checkSign(this.declaration, this.checkSign);
            role.getRes().guild.getGuild().basic.changeDeclaration(role, declaration);
        });
    }
}
